class DramaData {
  DramaData({
    this.createBy,
    this.createTime,
    this.updateBy,
    this.updateTime,
    this.remark,
    required this.id,
    required this.title,
    required this.desc,
    required this.epNumTotal,
    required this.playNum,
    required this.category,
    required this.coverImg,
    required this.data,
  });

  final dynamic createBy;
  final String? createTime;
  final dynamic updateBy;
  final dynamic updateTime;
  final dynamic remark;
  final int id;
  final String title;
  final String desc;
  final int epNumTotal;
  final int playNum;
  final int category;
  final String coverImg;
  final List<Drama> data;

  factory DramaData.fromJson(Map<String, dynamic> json) => DramaData(
    createBy: json['createBy'],
    createTime: json['createTime'] ?? '',
    updateBy: json['updateBy'],
    updateTime: json['updateTime'],
    remark: json['remark'],
    id: json['id'] ?? 0,
    title: json['title'] ?? '',
    desc: json['desc'] ?? '',
    epNumTotal: json['epNumTotal'] ?? 0,
    playNum: json['playNum'] ?? 0,
    category: json['category'] ?? 0,
    coverImg: json['coverImg'] ?? '',
    data: List<Drama>.from(json['data']?.map((x) => Drama.fromJson(x)) ?? []),
  );

  Map<String, dynamic> toJson() => {
    'createBy': createBy,
    'createTime': createTime,
    'updateBy': updateBy,
    'updateTime': updateTime,
    'remark': remark,
    'id': id,
    'title': title,
    'desc': desc,
    'epNumTotal': epNumTotal,
    'playNum': playNum,
    'category': category,
    'coverImg': coverImg,
    'data': List<dynamic>.from(data.map((x) => x.toJson())),
  };
}

class Drama {
  Drama({
    required this.id,
    required this.title,
    required this.desc,
    required this.epNumTotal, // 新增的字段
    required this.coverImg,
  });

  final int id;
  final String title;
  final String desc;
  final int epNumTotal; // 新增的字段
  final String coverImg;

  factory Drama.fromJson(Map<String, dynamic> json) => Drama(
    id: json['id'] ?? 0,
    title: json['title'] ?? '',
    desc: json['desc'] ?? '',
    epNumTotal: json['epNumTotal'] ?? 0, // 新增的字段
    coverImg: json['coverImg'] ?? '',
  );

  Map<String, dynamic> toJson() => {
    'id': id,
    'title': title,
    'desc': desc,
    'epNumTotal': epNumTotal, // 新增的字段
    'coverImg': coverImg,
  };
}
